// import $ from './lib/jquery';
import React from 'react';
import { render } from 'react-dom';
import Hooks from './common/hooks';
import tools from './common/tools';
import tips from './common/tips';
import Taber from './common/tab';
import Pinyin from './common/pinyin';
import Sheets from './sheets';
import Bodyer from './component/bodyer';
import grouper from './component/group';

class ChartMarker {
    constructor(host){
        this.host=host;
        this.hooks=new Hooks();
        this.file=null;
        this.init();
    }
    init(){
        let that=this;
        this.sheets=new Sheets('sheets-container');
        this.sheets.addHook('savechart',function(o){
            that.hooks.dispatch('savechart',o.params);
        })
        // 主UI
        render((
            <Bodyer/>
        ),document.querySelector('#app'));
    }
    // 编辑模板
    open(data,type){
        this.file=data||tools.generateSheets();
        this.sheets.open(this.file.sheets,type);
        let group={
            id:tools.uuid(),
            name:'临时分组',
            r:0,
            c:0,
            lr:0,
            lc:0,
            type:null
        }
        this.sheets.grouper.addItem(group.id,group);
        this.sheets.grouper.chartercontrol.dispatch('show',group);

        $('#g_chartmodalbox').css({
            display:'block',
            top:0
        }).find('.close').remove();
    }
}

export default ChartMarker;